﻿namespace MEF_Test.Bricks
{
    using System.Collections.Generic;
    using System.Windows;
    using System.Windows.Input;

    using MEF_Test.Contracts;

    public abstract class NodeActionBase : INodeAction
    {
        public NodeActionBase()
        {
            ActivateCommand = new ActionCommand<IBrowserNodeViewModel>(node => onExecuteActivateCommand(node), onCanExecuteActivateCommand);
        }

        /// <summary>
        /// A method called when the activate command is executed.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <returns></returns>
        protected abstract object onExecuteActivateCommand(IBrowserNodeViewModel node);


        /// <summary>
        /// A method called when the activate command is checked whether it can be executed.
        /// </summary>
        /// <returns></returns>
        protected virtual bool onCanExecuteActivateCommand()
        {
            return true;
        }


        public ICommand ActivateCommand { get; set; }

        #region INodeAction Members

        //abstract public ResourceDictionary Resources
        //{
        //    get ; 
        //}

        abstract public DataTemplate Template
        {
            get ;
        }

        #endregion

        #region INodeAction Members


        //public abstract bool Supports(IBrowserNodeViewModel browserNodeBase);
        public abstract IEnumerable<IActionContextProvider> GetCompatibleProviders(IBrowserNodeViewModel browserNodeBase);

        #endregion
    }

}
